<template>
  <div>
    <el-row>
      <el-button plain type="primary" @click="openData">搜索</el-button>
      <el-button plain type="primary" @click="openData">刷新</el-button>
    </el-row>
    <el-table
      :data="FCompanyList"
      border
      row-key="FCompanyID"
      default-expand-all
      :height="400"
      :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
    >
      <el-table-column prop="FCompanyCode" label="组织代码"> </el-table-column>
      <el-table-column prop="FCompanyName" label="组织简称"> </el-table-column>
      <el-table-column prop="FCompanyClassName" label="类别"></el-table-column>
      <el-table-column prop="FCompanyStatus" label="状态"></el-table-column>
      <el-table-column label="操作" width="100">
        <template #default="scope">
          <el-button
            @click="onPickCompany(scope.row)"
            type="primary"
            size="small"
            v-if="scope.row.FCompanyClassType != '集团'"
          >
            选择
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script  lang="ts">
import { Options, Vue } from "vue-class-component";
import TFormBase from "@/views/BaseForm";
import { TPersonRightCompany } from "@/baselib/right/BaseRightClass";
//配合着用
@Options({
  name: "TFormPersonCompanyPick",
  computed: {},
  data() {},
})
export default class TFormPersonCompanyPick extends TFormBase {
  private FCompanyList: TPersonRightCompany[] = [];
  public created() {
    this.openData();
  }
  private async openData() {
    let lResult =
      await this.$myBaseRightAPI.GetPersonCompanyBranchTreeByToken();
    if (!lResult.resultSuccess) {
      this.$myMsgHelp.msgDialog(lResult.resultMsg);
    }
    this.FCompanyList = lResult.resultData;
    this.$myMsgHelp.msgHintAutoClose("获取用户数据区域权限成功");
  }
  private onPickCompany(qPickCompany: TPersonRightCompany) {
    if (typeof this.zContextOnCall == "function") {
      this.zContextOnCall("pick", qPickCompany);
    }
  }
}
</script>